(*let memo f = 
	let h = Hashtbl.create 101 in
	function x ->
	try
		Hashtbl.find h x
	with
		Not_found ->
		let r = f x in
			Hashtbl.add h x r;
			r
*)
let memo_rec f =
	let h = Hashtbl.create 101 in
	let rec aux x =
	try 
		Hashtbl.find h x
	with
		Not_found ->
		let rest = f aux x in
		Hashtbl.add h x rest;
		rest	
	in aux


let count_fibo f = function
	(0 | 1) as x -> x 
	| x -> f (x-1) + f(x-2)

let fibo = memo_rec count_fibo


let main () =
	for i = 0 to 1000000 do
		ignore (fibo (Random.int 24))
	done;
	exit 0

let _ = main ()

(*
let mu f =
	let rec aux x = f aux x in
		aux


let mu_mieu f =
	let momei = memo f in
	let rec aux x = momei aux x in
		aux
		

let fact f = function 
	| 0 | 1 -> 1
	| n -> n * f (n-1)

*)
